var ul1 = document.getElementById("m303ul1");
var ul2 = document.getElementById("m303ul2");

function m303Init(){
	var uid = localStorage.getItem('uid');
	if(uid==null||uid=='')
	{
		mui.toast("请登陆后再进行此操作");
		mui.back();
	}
	var udata = {'uid':uid};
	m303ajax(udata);
}
function m303ajax(udata){
		mui.ajax(ASYURI+'A1014.do',{
		data:udata,
		dataType:'json',
		type:'post',
		timeout:10000,
		success : function(data){
			console.log(data);
			if(data.tag=='0')
			{
				var pub = data.publish;
				var ans = data.answered;
				if(pub.length==0)
				{
					var dive = divAInit();
					dive.appendChild(labelInit("您还没有发布任何问卷哦"))
					ul1.appendChild(dive);
				}else{
					var publen = pub.length;
					for(pubi = 0;pubi<publen;pubi++)
					{
						var spub = pub[pubi];
						var div = divAInit();
						var a = aInit(spub.A1010,spub.A1011);
						div.appendChild(a);
						ul1.appendChild(div);
					}
				}
				if(ans.length==0)
				{
					var dive = divAInit();
					dive.appendChild(labelInit("您还没有回答任何问卷哦"))
					ul2.appendChild(dive);
				}else{
					var anslen = ans.length;
					for(ansi = 0;ansi<anslen;ansi++)
					{
						var sans = ans[ansi];
						var div = divAInit();
						var a = aInit(sans.A1010,sans.A1011);
						div.appendChild(a);
						ul2.appendChild(div);
					}
				}
				
			}else if(data.tag=='2')
			{
				mui.toast("您还没有回答任何问卷哦");
			}
		},
		error : function(xhr,type,errorThrown){
			console.log(xhr+":"+type+"-"+errorThrown);
		}
	});
}
function divAInit(){
	var div1 = document.createElement("div");
	div1.setAttribute("class","mui-collapse-content");
	return div1;
}
function labelInit(value)
{
	var label = document.createElement("label");
	label.innerHTML = value;
	return label;
}
function aInit(aI1,aI2)
{
	var a = document.createElement("a");
	a.innerHTML= aI2;
	a.setAttribute("class","mui-navigate-right");
	a.setAttribute("onclick","openPage('"+aI1+"','"+aI2+"')");
	return a;
}
function openPage(op1,op2){
	localStorage.setItem("m303qid",op1);
	localStorage.setItem("m303title",op2);
	mui.openWindow("m3031.html");
}

m303Init();